package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import model.Tag;

public class TagDAO {
private Connection conn;

    public TagDAO(Connection conn) {
        this.conn = conn;
    }

    public boolean addTag(Tag tag) {
        String sql = "INSERT INTO tags (tag_name) VALUES (?)";
        try {
            PreparedStatement pstmt = conn.prepareStatement(sql);
            pstmt.setString(1, tag.getTagName());
            int rowsAffected = pstmt.executeUpdate();
            return rowsAffected > 0;
        } catch (SQLException e) {
            e.printStackTrace();
            return false;
        }
    }

    // 其他方法，如查询标签、更新标签信息等
}